package com.axialproject.health.exchange.entity;

public enum Gender {

    MALE (0, "MALE"),
    FEMALE (1, "FEMALE");

    private final int ordinalValue;
    private final String name;

    private Gender (int ordinalValue, String name){
        this.ordinalValue = ordinalValue;
        this.name = name;
    }

    public static Gender fromInt(int value) {
        switch(value) {
            case 0:  return Gender.MALE;
            case 1:  return Gender.FEMALE;
            default: return Gender.MALE;
        }
    }

    public static Gender fromName(String name) {
        if (Gender.MALE.getName().equals(name)) {
            return Gender.MALE;
        } else if (Gender.FEMALE.getName().equals(name)) {
            return Gender.FEMALE;
        } else {
            return Gender.MALE;
        }
    }

    public int getOrdinalValue() {
        return ordinalValue;
    }

    public String getName() {
        return name;
    }
}
